package com.gitee.wsl.common

import com.gitee.wsl.security.hash.hmacSha256
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import kotlin.test.Test


class sf {
    private val key = ByteArray(20) { it.toByte() }

    @Test
    fun testGF(){
        //Random.nextBytes(key)
        println("key:"+key.toHexString())
        val secKey = SecretKeySpec(key, "HMacSHA256")

        val test="adfafasf".encodeToByteArray()
        val mac = Mac.getInstance("HMacSHA256").apply { init(secKey) }
        println("macLength:"+mac.macLength)
        mac.update(test)
        val ret = mac.doFinal(test)
        println("retSize:"+ret.size)

        println("ret: "+ret.toHexString())
        val b = (test + test).hmacSha256(key).bytes
        println("b: "+b.toHexString())
        println("bSize: "+b.size)
    }

}